package com.usian.controller;

import com.usian.pojo.Team;
import com.usian.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Email 2781921355@qq.com
 * @Author 马忠豪
 * @Date 2023/8/22 11:01
 */
@RestController
@RequestMapping("log")
public class LogController {
    @Autowired
    private TestService testService;
    @Autowired
    private RedisTemplate redisTemplate;
    @RequestMapping("login")
    public String login(String consumerName,String password){
        String token = testService.getCToken(consumerName, password);
        return token;
    }
    @RequestMapping("getNumber")
    public Integer getNumber(){
        return testService.getNumber();
    }
    @RequestMapping("getCanNum")
    public Integer getCanNum(HttpServletRequest request){
        String token = request.getHeader("token");
        return testService.getCanNum(token);
    }
    @RequestMapping("getTeam")
    public List<Team> getTeam(){
        return testService.getTeam();
    }
    @RequestMapping("addOrUp")
    public void addOrUp(Integer id,HttpServletRequest request){
        String token = request.getHeader("token");
        testService.addOrUp(id,token);
    }
    @RequestMapping("getkanNumbe")
    public Integer getkanNumbe(){
        return testService.getkanNumbe();
    }
    @RequestMapping("getTeamName")
    public String getTeamName(HttpServletRequest request){
        String token = request.getHeader("token");
     return  testService.getTeamName(token);
    }
}
